<template>
  <div class="app-container calendar-list-container">
    <!-- filter 条件查询 -->
    <div class="filter-container">
      <el-input
        clearable
        @keyup.enter.native="handleFilter"
        v-model="listQuery.nickName"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
        class="filter-item"
        placeholder="请输入昵称"
      />
      <el-input
        clearable
        @keyup.enter.native="handleFilter"
        v-model="listQuery.userPhone"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
        class="filter-item"
        placeholder="请输入手机号"
      />
      <el-input
        clearable
        @keyup.enter.native="handleFilter"
        v-model="listQuery.equipmentNumber"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
        class="filter-item"
        placeholder="请输入设备编号"
      />
      <el-input
        clearable
        @keyup.enter.native="handleFilter"
        v-model="listQuery.mouthNoShow"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
        class="filter-item"
        placeholder="请输入格口编号"
      />
      <el-input
        clearable
        @keyup.enter.native="handleFilter"
        v-model="listQuery.outTradeNo"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
        class="filter-item"
        placeholder="请输入支付流水号"
      />
      <br />

      <el-select
        v-model="listQuery.payStatus"
        placeholder="请选择订单状态"
        clearable
        class="filter-item"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
      >
        <el-option label="待充电" value="1"></el-option>
        <el-option label="充电失败" value="2"></el-option>
        <el-option label="进行中" value="3"></el-option>
        <el-option label="待支付" value="4"></el-option>
        <el-option label="已支付" value="5"></el-option>
        <el-option label="不计费" value="6"></el-option>
        <el-option label="退款" value="7"></el-option>
      </el-select>

      <el-select
        v-model="listQuery.payType"
        placeholder="请选择支付类型"
        clearable
        class="filter-item"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
      >
        <el-option label="微信" value="1"></el-option>
        <el-option label="余额" value="3"></el-option>
        <el-option label="会员卡" value="4"></el-option>
        <el-option label="ic卡" value="5"></el-option>
      </el-select>
      <el-input
        clearable
        @keyup.enter.native="handleFilter"
        v-model="listQuery.cardNo"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
        class="filter-item"
        maxlength="20"
        placeholder="请输入会员卡/Ic卡标识码"
      />

 <!-- 2022.09.07  合并为时间日期选择器 -->
      <el-date-picker
        v-model="dateTime"
        type="datetimerange"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="yyyy-MM-dd HH:mm:00"
        @change="getDateTime"
      >
      </el-date-picker>
      <!-- <el-date-picker
        v-model="listQuery.startTime"
        type="datetime"
        value-format="yyyy-MM-dd HH:mm:ss"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
        placeholder="选择开始日期"
      ></el-date-picker>
      <el-date-picker
        v-model="listQuery.endTime"
        type="datetime"
        style="width: 200px; margin-right: 15px; margin-top: 7px"
        value-format="yyyy-MM-dd HH:mm:ss"
        placeholder="选择结束日期"
      ></el-date-picker> -->

      <br />

      <el-button
        class="filter-item"
        type="primary"
        v-waves
        icon="el-icon-search"
        @click="handleFilter"
        >查找</el-button
      >
      <el-button
        type="primary"
        class="filter-item"
        @click="handleDownload"
        icon="el-icon-download"
        :loading="downloadLoading"
        >导出</el-button
      >
    </div>
    <!-- table 表格 -->
    <el-table
      :data="list"
      v-loading="loading.list"
      element-loading-text="给我一点时间"
      border
      fit
      highlight-current-row
      style="width: 100%"
      max-height="830"
    >
      <el-table-column label="序号" prop="index" align="center" width="50px" />
      <el-table-column label="昵称" prop="nickName" align="center" />
      <el-table-column label="手机号" prop="userPhone" align="center" />
      <el-table-column label="设备编号" prop="equipmentNumber" align="center" />
      <el-table-column label="格口编号" prop="mouthNoShow" align="center" />
      <el-table-column label="支付流水号" prop="outTradeNo" align="center" />
      <el-table-column label="支付类型" prop="payTypeInfo" align="center" />
      <el-table-column label="会员卡/Ic卡标识码" prop="cardNo" align="center" />
      <el-table-column label="订单类型" prop="orderTypeInfo" align="center" />
      <el-table-column label="功率(w)" prop="power" align="center" />
      <el-table-column label="使用时长" prop="time" align="center" />
      <el-table-column label="免费时长" prop="freeTimeInfo" align="center" />
      <el-table-column label="订单状态" prop="payStatusInfo" align="center" />
      <el-table-column
        label="订单金额(元)"
        prop="orderAmountInfo"
        align="center"
      />
      <el-table-column label="下单时间" prop="ctime" align="center" />
      <el-table-column label="结束时间" prop="etime" align="center" />
      <el-table-column label="结束原因" prop="endReasonInfo" align="center" />

      <el-table-column
        label="操作"
        class-name="small-padding fixed-width"
        align="center"
        width="100px"
      >
        <template slot-scope="scope">
          <router-link
            :to="{ name: 'orderDetail', query: { orderId: scope.row.orderId } }"
          >
            <el-button type="info" class="Bot-bt">详情</el-button>
          </router-link>

          <el-button
            size="small"
            type="warning"
            @click="refundOrderView(scope.row)"
            v-show="
              (scope.row.payType == 3 || scope.row.payType == 5) &&
              scope.row.payStatus == 5 &&
              scope.row.orderAmountInfo > 0
            "
            class="Bot-bt"
            >退款</el-button
          >
          <el-button
            style="margin-left: 0px"
            size="small"
            v-show="scope.row.payStatus == 3"
            type="danger"
            @click="endOrderQueryView(scope.row)"
            >结束订单</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <!-- 退款 -->
    <el-dialog title="退款" :visible.sync="dialog1.add">
      <el-form
        :model="refundQuery"
        :rules="bindRules"
        ref="bindForm"
        label-position="right"
        label-width="150px"
      >
        <!-- <div style="margin-left: 10%;margin-bottom: 20px;" >
        <el-radio v-model="refundQuery.type"   :label=1 @change="resetMoney()"  >手动退款</el-radio>
       <el-radio v-model="refundQuery.type"    :label=2 @change="resetMoney()" >全额退款</el-radio>
    </div> -->
        <el-form-item label="支付-实际金额(元)">
          <div style="color: green">{{ this.refundQuery.actualAmount }}</div>
        </el-form-item>

        <el-form-item label="退款-实际金额(元)" prop="orderRefundAmount">
          <el-input
            :disabled="refundQuery.type == 2"
            type="number"
            clearable
            v-model="refundQuery.orderRefundAmount"
            placeholder="请输入退款金额(元)，大于等于0的两位小数"
          ></el-input>
        </el-form-item>
        <el-form-item label="支付-赠送金额(元)">
          <div style="color: green">{{ this.refundQuery.givenAmount }}</div>
        </el-form-item>
        <el-form-item label="退款-赠送金额(元)" prop="orderRefundGivenAmount">
          <el-input
            :disabled="refundQuery.type == 2"
            type="number"
            clearable
            v-model="refundQuery.orderRefundGivenAmount"
            placeholder="请输入退款赠送金额(元)，大于等于0的两位小数"
          ></el-input>
        </el-form-item>

        <div style="color: red"></div>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialog1.add = false">取消</el-button>
        <el-button
          type="primary"
          :loading="loading.add"
          @click="updateRefundOrder"
          >确定</el-button
        >
      </div>
    </el-dialog>
    <!-- 结束订单 -->
    <el-dialog title="结束订单" :visible.sync="dialog1.end">
      <el-form
        :model="endOrderQuery"
        :rules="endRules"
        ref="bindForm2"
        label-position="right"
        label-width="150px"
      >
        <el-form-item label="结束方式：">
          <el-radio
            v-model="endOrderQuery.type"
            :disabled="endOrderQuery.payStatus == 3"
            :label="0"
            >发命令结束</el-radio
          >
          <el-radio
            v-model="endOrderQuery.type"
            :disabled="endOrderQuery.payStatus == 3"
            :label="2"
            >按当前数据结束</el-radio
          >
          <el-radio
            v-model="endOrderQuery.type"
            :disabled="endOrderQuery.payStatus == 3"
            :label="1"
            @change="
              getDetailsOrder(endOrderQuery.orderId, endOrderQuery.payType)
            "
            >手动结束</el-radio
          >
          <br />
          <div v-show="endOrderQuery.type == 0" style="color: red">
            下发关锁命令，进行结束。
          </div>
          <div v-show="endOrderQuery.type == 2" style="color: red">
            按当前 使用时长 和 功率 计算，进行结束 （数据更新周期为一小时）。
          </div>
        </el-form-item>
        <el-form-item
          label="支付金额范围："
          v-show="endOrderQuery.type == 1 && endOrderQuery.payType != 4"
        >
          <span>
            最低金额 {{ 0 }} 元 - 最高金额
            {{ this.endOrderQuery.tallAmount }} 元
          </span>
        </el-form-item>
        <el-form-item
          style="margin-bottom: 20px"
          v-if="endOrderQuery.type == 1 && endOrderQuery.payType != 4"
          label="支付金额(元)："
          prop="orderAmount"
        >
          <el-input
            clearable
            v-model="endOrderQuery.orderAmount"
            placeholder="请输入支付金额 大于等于0的两位小数"
          ></el-input>
        </el-form-item>

        <el-form-item
          label="时长范围："
          v-show="endOrderQuery.type == 1 && endOrderQuery.payType == 4"
        >
          <span> 最低时长 0 小时 - 最高时长 8 小时 </span>
        </el-form-item>
        <el-form-item
          style="margin-bottom: 20px"
          v-if="endOrderQuery.type == 1 && endOrderQuery.payType == 4"
          label="使用时长(小时)："
          prop="useTimeQuantum"
        >
          <el-input
            clearable
            v-model="endOrderQuery.useTimeQuantum"
            placeholder="请输入使用时长 大于等于0的两位小数"
          ></el-input>
        </el-form-item>
        <div
          v-show="endOrderQuery.type == 1"
          style="color: red; margin-left: 10%; margin-bottom: 20px"
        >
          手动输入 金额/时长 ，进行结束。
        </div>
        <div
          v-show="endOrderQuery.type == 1"
          style="color: red; margin-left: 10%; margin-bottom: 20px"
        >
          注意：不关注 订单是否在免费时长内 和 最低金额限制，金额/时长
          按输入的收取。
        </div>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialog1.end = false">取消</el-button>
        <el-button type="primary" :loading="loading.end" @click="endBackOrder"
          >确定</el-button
        >
      </div>
    </el-dialog>
    <!-- pagination 分页 -->
    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="listQuery.offset"
        :page-sizes="[10, 20, 30, 40, 100, 300, 500, 5000, 10000]"
        :page-size="listQuery.limit"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import {
  getList,
  endOrder,
  endBackOrder,
  refundOrder,
  calculateMoney,
  getDetailsOrder,
} from "@/api/equipmentOrders";
import { parseTime, getdTime, getdTimeHour } from "@/utils/index";
export default {
  name: "equipmentOrders_list",
  data() {
    var validateAmount = (rule, value, callback) => {
      var value = new Number(value);
      if (!value) {
        return callback(new Error("金额不能为空!"));
      }
      setTimeout(() => {
        var isNum = /^(([0-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
        if (!isNum.test(value)) {
          callback(new Error("请输入正确金额,金额不能小于0，两位小数以内!"));
        } else {
          if ((value + "").length > 12) {
            callback(new Error("金额超过范围12位"));
          }
          if (value > this.refundQuery.actualAmount) {
            callback(new Error("金额超过可退范围!"));
          }

          if (value + this.refundQuery.orderRefundGivenAmount == 0) {
            callback(new Error("退款金额之和不能小于等于0!"));
          }
          callback();
        }
      }, 300);
    };

    var validateGivenAmount = (rule, value, callback) => {
      var value = new Number(value);
      if (!value) {
        return callback(new Error("金额不能为空!"));
      }
      setTimeout(() => {
        var isNum = /^(([0-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
        if (!isNum.test(value)) {
          callback(new Error("请输入正确金额,金额不能小于0，两位小数以内!"));
        } else {
          if ((value + "").length > 12) {
            callback(new Error("金额超过范围12位"));
          }

          if (value > this.refundQuery.givenAmount) {
            callback(new Error("金额超过可退范围!"));
          }

          if (value + this.refundQuery.orderRefundAmount == 0) {
            callback(new Error("退款金额之和不能小于等于0!"));
          }

          callback();
        }
      }, 300);
    };

    var validateEndAmount = (rule, value, callback) => {
      //   if(this.endOrderQuery.payType!=4){
      var value = new Number(value);
      // console.log("========"+value)
      if (!value) {
        return callback(new Error("金额不能为空!"));
      }
      setTimeout(() => {
        var isNum = /^(([0-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
        if (!isNum.test(value)) {
          callback(new Error("请输入正确金额,金额不能小于0，两位小数以内!"));
        } else {
          if (value > this.endOrderQuery.tallAmount) {
            callback(new Error("支付金额超过范围!"));
          }
          if ((value + "").length > 12) {
            callback(new Error("金额超过范围12位"));
          }
          callback();
        }
      }, 300);
      // console.log("rule1")
      //    }
    };

    var validateUseTimeQuantum = (rule, value, callback) => {
      var value = new Number(value);
      if (!value) {
        return callback(new Error("时长不能为空!"));
      }
      setTimeout(() => {
        var isNum = /^(([0-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/;
        if (!isNum.test(value)) {
          callback(new Error("请输入正确时长,两位小数以内!"));
        } else {
          if (value > 8 || value < 0) {
            callback(new Error("时长超过范围,8小时内!"));
          }
          if ((value + "").length > 6) {
            callback(new Error("时长超过范围6位"));
          }
          callback();
        }
      }, 300);
      // console.log("rule2")
    };

    return {
      dateTime:"",
      total: 0,
      listQuery: {
        offset: 1,
        limit: 10,
        nickName: "",
        userPhone: "",
        cardNo: "",
        equipmentNumber: "",
        mouthNoShow: "",
        outTradeNo: "",
        payStatus: "",
        payType: "",
        startTime: "",
        endTime: "",
      },
      refundQuery: {
        orderRefundAmount: "",
        orderRefundGivenAmount: "",
        orderRefundReason: "",
        orderId: "",
        orderType: "",
        payStatus: "",
        type: 1,
      },
      endOrderQuery: {
        orderId: "",
        type: "",
        payStatus: "",
        tallAmount: "",
        lowAmount: "",
        equipmentNumber: "",
        payType: "",
        timeType: "",
        orderAmount: "",
        deviceId: "",
        mouthNo: "",
        power: "",
        useTimeQuantum: "",
        time: "",
        freeTimeInfo: "",
        uTimeInfo: "",
        freeTime: "",
        uTime: "",
      },
      bindRules: {
        orderRefundAmount: [
          { required: true, validator: validateAmount, trigger: "change" },
        ],
        orderRefundGivenAmount: [
          { required: true, validator: validateGivenAmount, trigger: "change" },
        ],
        orderRefundReason: [
          { required: true, message: "请输入退款原因", trigger: "change" },
        ],
        type: [{ required: true, message: "请选择", trigger: "change" }],
      },

      endRules: {
        orderAmount: [
          { required: true, validator: validateEndAmount, trigger: "blur" },
        ],
        useTimeQuantum: [
          {
            required: true,
            validator: validateUseTimeQuantum,
            trigger: "blur",
          },
        ],
      },
      bindRules2: {},
      dialog1: {
        add: false,
        end: false,
      },

      list: null,
      loading: {
        end: false,
        list: false,
        download: false,
      },
      categoryList: [],
      downloadLoading: false,
    };
  },
  methods: {
        getDateTime(value) {
      if (value) {
        this.listQuery.startTime = value[0];
        this.listQuery.endTime = value[1];
      } else {
        this.listQuery.startTime = "";
        this.listQuery.endTime = "";
      }
    },
    //导出
    handleDownload() {
      this.downloadLoading = true;
      import("@/vendor/Export2Excel").then((excel) => {
        const tHeader = [
          "昵称",
          "手机号",
          "设备编号",
          "端口编号",
          "支付流水号",
          "支付类型",
          "会员卡/Ic卡",
          "订单类型",
          "功率(w)",
          "使用时长",
          "免费时长",
          "订单状态",
          "订单金额(元)",
          "下单时间",
          "结束时间",
          "结束原因",
        ];
        const filterVal = [
          "nickName",
          "userPhone",
          "equipmentNumber",
          "mouthNoShow",
          "outTradeNo",
          "payTypeInfo",
          "cardNo",
          "orderTypeInfo",
          "power",
          "time",
          "freeTimeInfo",
          "payStatusInfo",
          "orderAmountInfo",
          "ctime",
          "etime",
          "endReasonInfo",
        ];

        const data = this.formatJson(filterVal, this.list);
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: "充电订单列表",
        });
        this.downloadLoading = false;
      });
    },

    // 数据筛选
    formatJson(filterVal, jsonData) {
      return jsonData.map((v) =>
        filterVal.map((j) => {
          return v[j];
        })
      );
    },

    resetForm(flag) {
      this.$refs.bindForm && this.$refs.bindForm.resetFields();
      if (flag) {
        this.refundQuery = {
          id: "",
        };
      }
    },
    refundOrderView(row) {
      this.resetForm();
      this.dialog1.add = true;
      this.refundQuery.type = 1;
      this.refundQuery.orderType = row.orderType;
      this.refundQuery.orderId = row.orderId;
      this.refundQuery.payStatus = row.payStatus;
      this.refundQuery.actualAmount =
        row.actualAmountInfo - row.orderRefundAmountInfo;
      this.refundQuery.givenAmount =
        row.givenAmountInfo - row.orderRefundGivenAmountInfo;
      this.refundQuery.orderRefundAmount =
        row.actualAmountInfo - row.orderRefundAmountInfo;
      this.refundQuery.orderRefundGivenAmount =
        row.givenAmountInfo - row.orderRefundGivenAmountInfo;
    },

    async resetMoney() {
      this.refundQuery.orderRefundAmount = this.refundQuery.actualAmount;
      this.refundQuery.orderRefundGivenAmount = this.refundQuery.givenAmount;
    },

    async getDetailsOrder(orderId, payType) {
      try {
        //支付类型 1:微信 2:支付宝 3:余额 4会员卡 5ic卡
        if (payType != 4) {
          const { data } = await getDetailsOrder({ orderId: orderId });
          if (data) {
            this.endOrderQuery.lowAmount = data.orderMeal.lowAmount / 100;
            this.endOrderQuery.tallAmount = data.orderMeal.tallAmount / 100;
            this.endOrderQuery.orderAmount = 0;
          }
        }
        {
          this.endOrderQuery.useTimeQuantum = 0;
        }
      } catch (error) {}
    },

    async calculateMoney(orderId) {
      try {
        //调用服务器接口
        const { data } = await calculateMoney({ orderId: orderId });
        var orderRefundAmount = 0;
        var orderRefundGivenAmount = 0;
        if (data) {
          orderRefundAmount = data.orderRefundAmount / 100;
          orderRefundGivenAmount = data.orderRefundGivenAmount / 100;
        }
        this.refundQuery.orderRefundAmount = 0;
        this.refundQuery.orderRefundGivenAmount = 0;
      } catch (error) {}
    },
    //手动退款
    async updateRefundOrder() {
      this.$refs["bindForm"].validate(async (valid) => {
        if (valid) {
          try {
            this.loading.add = true;
            let query = {
              orderId: this.refundQuery.orderId,
              orderRefundAmount: this.refundQuery.orderRefundAmount * 100,
              orderRefundGivenAmount:
                this.refundQuery.orderRefundGivenAmount * 100,
              orderRefundReason: this.refundQuery.orderRefundReason,
            };

            this.loading.add = true;
            //调用服务器接口
            const { data } = await refundOrder(query);
            this.$message({
              type: "success",
              message: "退款成功",
            });
            this.dialog1.add = false;
            this.loading.add = false;
            this.resetForm();
            this.getList();
          } catch (error) {
            this.loading.add = false;
            this.resetForm();
          }
        }
      });
    },
    resetForm2(flag) {
      this.$refs.bindForm2 && this.$refs.bindForm2.resetFields();
      if (flag) {
        this.endOrderQuery = {
          id: "",
        };
      }
    },
    endOrderQueryView(data) {
      this.resetForm2();
      this.dialog1.end = true;
      this.endOrderQuery.orderId = data.orderId;
      this.endOrderQuery.equipmentNumber = data.equipmentNumber;
      this.endOrderQuery.type = 0;
      this.endOrderQuery.payType = data.payType;
      this.endOrderQuery.timeType = 0;
      this.endOrderQuery.ctime = new Date(data.ctime).getTime();
      this.endOrderQuery.uTimeInfo = data.time;
      this.endOrderQuery.freeTimeInfo = data.freeTimeInfo;
      this.endOrderQuery.deviceId = data.deviceId;
      this.endOrderQuery.mouthNo = data.mouthNo;
      this.endOrderQuery.power = data.power;
      this.endOrderQuery.uTime = data.useTimeQuantum ? data.useTimeQuantum : 0;
      this.endOrderQuery.freeTime = data.freeTime;
    },

    //结束
    async endBackOrder() {
      this.$refs["bindForm2"].validate(async (valid) => {
        // console.log(valid)
        if (valid) {
          try {
            this.loading.end = true;
            let query = {
              orderId: this.endOrderQuery.orderId,
              orderAmount: this.endOrderQuery.orderAmount * 100,
              type: this.endOrderQuery.type,
              equipmentNumber: this.endOrderQuery.equipmentNumber,
              useTimeQuantum: this.endOrderQuery.useTimeQuantum * 3600000,
              deviceId: this.endOrderQuery.deviceId,
              mouthNo: this.endOrderQuery.mouthNo,
            };
            //调用服务器接口
            const { data } = await endBackOrder(query);
            this.$message({
              type: "success",
              message: "结束成功",
            });
            this.dialog1.end = false;
            this.loading.end = false;
            this.resetForm2();
            this.getList();
          } catch (error) {
            this.loading.end = false;
            this.resetForm2();
          }
        }
      });
    },

    //获取设备订单列表
    async getList() {
      this.loading.list = true;
      try {
        //调用服务器接口
        const { data } = await getList({ ...this.listQuery });
        this.list = data.records.map((item, index) => {
          return {
            index: index + 1,
            orderTypeInfo: item.orderType == 1 ? "按次" : "按时间",
            orderAmountInfo: item.payType != 4 ? item.orderAmount / 100 : "-",
            time:
              item.orderType == 2 ? getdTime(item.useTimeQuantum / 1000) : "",
            freeTimeInfo: getdTime(item.freeTime / 1000),

            orderRefundGivenAmountInfo: item.orderRefundGivenAmount / 100,
            cardOutTradeNo:
              item.payType == 4 || item.payType == 5
                ? item.cardOutTradeNo
                : "-",
            orderRefundAmountInfo: item.orderRefundAmount / 100,
            orderRefundReason: item.orderRefundReason
              ? item.orderRefundReason
              : "-",
            payTypeInfo:
              item.payType == 1
                ? "微信"
                : item.payType == 2
                ? "支付宝"
                : item.payType == 3
                ? "余额"
                : item.payType == 4
                ? "会员卡"
                : item.payType == 5
                ? "ic卡"
                : "-",
            payStatusInfo:
              item.payStatus == 1
                ? "待充电"
                : item.payStatus == 2
                ? "充电失败"
                : item.payStatus == 3
                ? "进行中"
                : item.payStatus == 4
                ? "待支付"
                : item.payStatus == 5
                ? "已支付"
                : item.payStatus == 6
                ? "不计费"
                : item.payStatus == 7
                ? "退款"
                : "-",
            endReasonInfo: !(item.payStatus == 1 || item.payStatus == 3)
              ? item.endReason == 0
                ? "正常结束"
                : item.endReason == 1
                ? "未使用结束"
                : item.endReason == 2
                ? "电池充满"
                : item.endReason == 3
                ? "异常结束:限额充电"
                : item.endReason == 4
                ? "异常结束:电池识别异常"
                : item.endReason == 5
                ? "异常结束:输出短路故障"
                : item.endReason == 6
                ? "异常结束:输出过压"
                : item.endReason == 7
                ? "异常结束:输出过流"
                : item.endReason == 8
                ? "异常结束:系统过温"
                : item.endReason == 9
                ? "异常结束:NTC异常"
                : item.endReason == 10
                ? "异常结束:电池故障"
                : item.endReason == 11
                ? "异常结束:负载断电"
                : item.endReason == 12
                ? "异常结束:电源故障"
                : item.endReason == 13
                ? "异常结束:通讯超时"
                : item.endReason == 14
                ? "异常结束:过压关机"
                : item.endReason == 15
                ? "异常结束:电池反接"
                : item.endReason == 16
                ? "异常结束:充电超时"
                : "人工结束"
              : "-",
            actualAmountInfo: item.actualAmount / 100,
            givenAmountInfo: item.givenAmount / 100,
            ...item,
          };
        });
        this.total = data.total;
      } catch (error) {}
      this.loading.list = false;
    },
    handleFilter() {
      this.listQuery.offset = 1;
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.limit = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.offset = val;
      this.getList();
    },
    formatDate(date, offset) {
      if (date && typeof date == "object") {
        const d = date[offset];
        return new Date(d).getTime();
      }
      return "";
    },
  },
  created() {
    this.getList();
  },
};
</script>
<style lang="scss" scoped>
.Bot-bt {
  margin-bottom: 8px;
}
</style>